package com.roadjava.tutor.util;

import org.apache.commons.lang3.StringUtils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author zhaodaowen
 * @see <a href="http://www.roadjava.com">乐之者java</a>
 */
public class DateUtil {
    private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public static LocalDateTime str2Date(String str) {
        if (StringUtils.isBlank(str)) {
            return null;
        }
        return LocalDateTime.from(formatter.parse(str));
    }
    public static String date2Str(LocalDateTime localDateTime) {
        return formatter.format(localDateTime);
    }
}
